﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

#if NETFX_CORE || WINDOWS_PHONE
using EnvironmentApplicationData = WindowsCommonStorage.NetFxCoreApplicationData;
#else
using EnvironmentApplicationData = WindowsCommonStorage.NetFxApplicatonData;
#endif

namespace WindowsCommonStorage
{
    public abstract class CommonAppllicationData
    {
        public CommonStorageFolder LocalFolder
        {
            get
            {
                return ErrorHandler.Func(() =>
                {
                    return ProtectedLocalFolder;
                });
            }
        }
        internal protected abstract CommonStorageFolder ProtectedLocalFolder { get; }


        public CommonStorageFolder RomingFolder
        {
            get
            {
                return ErrorHandler.Func(() =>
                {
                    return ProtectedRomingFolder;
                });
            }
        }
        internal protected abstract CommonStorageFolder ProtectedRomingFolder { get; }

        public CommonStorageFolder TemporaryFolder
        {
            get
            {
                return ErrorHandler.Func(() =>
                {
                    return ProtectedTemporaryFolder;
                });
            }
        }
        internal protected abstract CommonStorageFolder ProtectedTemporaryFolder { get; }

        public async Task ClearAsync()
        {
            await ErrorHandler.AsyncAction(async () =>
            {
                await ProtectedClearAsync().ConfigureAwait(false);
            }).ConfigureAwait(false);
        }
        internal protected abstract Task ProtectedClearAsync();



        internal protected CommonAppllicationData()
        {

        }

        public static CommonAppllicationData Current
        {
            get
            {
                return EnvironmentApplicationData._current;
            }
        }
    }
}
